package com.cwd.arm.inter.controller;

import com.cwd.arm.application.service.read.facade.AuthReadService;
import com.cwd.arm.common.dto.session.AuthDto;
import com.cwd.arm.inter.util.DtoToVoUtil;
import com.cwd.arm.inter.vo.ResponseVo;
import com.cwd.arm.inter.vo.auth.AuthVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by yan on 21-12-25.
 */
@Api(value = "权限接口", description = "权限接口")
@RestController
@RequestMapping(value = "/auth")
public class AuthController {

    @Autowired
    private AuthReadService readService;

    @ApiOperation(value = "查询所有权限信息", notes = "查询所有权限信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "authType", value = "权限类型:菜单menu;按钮btn",required = true,dataType = "String")
    })
    @GetMapping("")
    public ResponseVo<List<AuthVo>> getAuthList(String authType) {
        List<AuthDto> authDtoList = readService.selectByType(authType);
        return ResponseVo.<List<AuthVo>>BUILDER().success(DtoToVoUtil.convertToAuthVoList(authDtoList));
    }
}
